package oss.aliyun.springai.Controller;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import oss.aliyun.springai.service.ICourseService;

import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CJ
 * @since 2025-06-02
 */
@RestController
@RequestMapping("/ai")
public class CourseController {
    @Autowired
     private ICourseService courseService;
    @Autowired
     private ChatClient  ServicechatClient;
   @GetMapping ("/service")
    public String service(String  prompt, String chatId){
       return   ServicechatClient.prompt()
               .user(prompt)
               .advisors(a -> a.param(CHAT_MEMORY_CONVERSATION_ID_KEY, chatId))
               .call()
               .content();
    }
}
